<!DOCTYPE html>
<html ng-app="myApp">

<head>
    <title>has和get方法</title>
    <meta charset="utf-8">
    <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>

<body>
    <script type="text/javascript">
    angular.module('a4_6', []).factory('$custom', function() {
            return {
            	print: function (msg) {
            		console.log(msg);
            	}
            }
        });
    var injector = angular.injector(['a4_6','ng']);
    var has = injector.has('$custom');
    console.log(has);
    if (has) {
    	var custom = injector.get('$custom');
    	custom.print("控制台输出任意内容");
    }


    </script>
</body>

</html>
